//
//  ScanFullBoxVC.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2020/7/28.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "ScanFullBoxVC.h"
#import "ScanBoxCell.h"
#import "ScanFullBoxCell.h"

@interface ScanFullBoxVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UIView *bottomView;
@property (nonatomic, strong) UITableView *tableView;

@end

@implementation ScanFullBoxVC

-(UIView *)bottomView {
    if (!_bottomView) {
        _bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, ScreenH - BottomHeight - NaviHeight - 64, ScreenW, 64+BottomHeight)];
        _bottomView.backgroundColor = HexColor(0xffffff);
        UIButton *editBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenW - 30 - 90, 10, 90, 44)];
        [editBtn setBackgroundColor:HexColorA(0x3D68EB, 0.1)];
        editBtn.layer.masksToBounds = YES;
        editBtn.layer.cornerRadius = 6;
        [editBtn setTitle:@"编辑" forState:0];
        [editBtn setTitleColor:Color_ThemeColor forState:0];
        editBtn.titleLabel.font = BoldFontOfSize(16);
        [editBtn addTarget:self action:@selector(editClick) forControlEvents:UIControlEventTouchUpInside];
        [_bottomView addSubview:editBtn];
        
        UIButton *jieChuBtn = [[UIButton alloc] initWithFrame:CGRectMake(30, 10, editBtn.nim_left - 15 - 30, 44)];
        [jieChuBtn setBackgroundColor:HexColorA(0xFBA962, 0.1)];
        jieChuBtn.layer.masksToBounds = YES;
        jieChuBtn.layer.cornerRadius = 6;
        [jieChuBtn setTitle:@"解除货物绑定" forState:0];
        [jieChuBtn setTitleColor:HexColor(0xFBA962) forState:0];
        jieChuBtn.titleLabel.font = BoldFontOfSize(16);
        [jieChuBtn addTarget:self action:@selector(jieChuClick) forControlEvents:UIControlEventTouchUpInside];
        [_bottomView addSubview:jieChuBtn];
    }
    return _bottomView;
}

//编辑
- (void)editClick {
    
}

//解除货物绑定
- (void)jieChuClick {
    
}

-(UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, ScreenH - self.bottomView.nim_height - NaviHeight)];
        _tableView.backgroundColor = Color_backgroundColor;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _tableView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"扫一扫";
    [self.view addSubview:self.bottomView];
    [self.view addSubview:self.tableView];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        ScanBoxCell *cell = [ScanBoxCell ScanBoxCellWithTableView:tableView];
        cell.model = self.boxModel;
        return cell;
    }
    ScanFullBoxCell *cell = [ScanFullBoxCell ScanFullBoxCellWithTableView:tableView];
    cell.model = self.boxModel;
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        ScanBoxCell *cell = [ScanBoxCell ScanBoxCellWithTableView:tableView];
        return cell.height;
    }
    ScanFullBoxCell *cell = [ScanFullBoxCell ScanFullBoxCellWithTableView:tableView];
    return cell.height;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
